﻿using System;
using Castle.Core.Interceptor;

namespace XWord.Common.Attributes
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
    public class HandleExceptionAttribute : MethodCallAttribute, IPredicate<IInvocation, Exception>
    {
        protected HandleExceptionAttribute()
        { }

        public HandleExceptionAttribute(string methodName)
            : base(methodName)
        { }

        public virtual bool Predicate(IInvocation invocation, Exception ex)
        {
            return true;
        }
    }
}
